package com.jzo2o.market.controller.Operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author LeeC
 * @description
 * @date 2025/2/11
 * @PACKAGE_NAME com.jzo2o.market.controller
 */
@RestController("marketOperationActivityController")
@RequestMapping("/operation/activity")
@Api(tags = "运营端 - 活动管理")
public class OperationActivityController {
    @Resource
    private IActivityService activityService;
    @PostMapping("/save")
    @ApiOperation("保存活动")
    public void save(@RequestBody ActivitySaveReqDTO activitySaveReqDTO) {
        activityService.save(activitySaveReqDTO);
    }

    @GetMapping("/page")
    @ApiOperation("分页查询活动")
    public PageResult<ActivityInfoResDTO> page(ActivityQueryForPageReqDTO pageReqDTO) {
        return activityService.page(pageReqDTO);
    }

    @PostMapping("/revoke/{id}")
    @ApiOperation("撤销活动接口")
    public void revoke(@PathVariable Long id) {
        activityService.revoke(id);
    }

    /**
     * 根据id查询活动信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询活动信息")
    public ActivityInfoResDTO getById(@PathVariable Long id) {
        return activityService.getById(id);
    }
}
